package com.opennice.soukaoti.paper.dao.impl;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.opennice.soukaoti.dao.BaseDAO;
import com.opennice.soukaoti.paper.dao.IPaperDAO;
import com.opennice.soukaoti.vo.Paper;

public class PaperDAO extends BaseDAO implements IPaperDAO {
	@Override
	public Paper getPaper(int pid) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		Paper paper = (Paper) session.load(Paper.class, pid);
		tx.commit();
		session.close();
		return paper;
	}

	@Override
	public void savePaper(Paper paper) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.save(paper);
		tx.commit();
		session.close();
	}

	@Override
	public void updatePaper(Paper paper) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.update(paper);
		tx.commit();
		session.close();
	}

}
